﻿///
/// Copyright, 
/// This application , code and content is free to copy and modify 
/// This code is for demo purposed only 
/// User at own risk. no legal obligations from my end.
/// The purpose of this code is to explore the SharePoint Audit facilities.
/// George Gergues , george.gergues@gmail.com
/// Thank you.
///

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace TIS.SPAuditDemo
{
    class SPCustomUsersCache
    {
        internal Dictionary<int, SPUser> localCache = new Dictionary<int, SPUser>();

        public void AddUser(int UserId , SPUser User)
        {
            try
            {
                localCache.Add(UserId, User);
            }
            catch
            {
            }
        }

        public SPUser findUser(int i)
        {
            
            SPUser foundUser ;
            try
            {
                ///If found this will be true.
                if (this.localCache.TryGetValue(i, out foundUser))
                    return foundUser;
                else
                    //Not found, at consuming class, check if the User.ID is 0
                    return null;
            }
            catch
            {
                return null;
            }
        }

    }
}
